import service from "./api";
import gpt_api from "./gpt_api";
import removeWatermark from "./removeWatermark"

//去水印
export const gpt = (msg) => gpt_api({
  url: "/v1/chat/completions",
  method: "post",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer fk214774-1ldILA3DForOsWcBgE0KH0G6FMsE9QXf",
  },
  data: {
    model: "gpt-3.5-turbo",
    messages: [
      {
        role: "user",
        content: msg
      }
    ],
    "safe_mode": false
  }
})

//去水印
export const removeWatermarkNet = (url) => service({
  url: "/api/index/videos_eeapi?url=" + url,
  method: "post",
})

// 获取身份
// export const roleapi = () => service({
//   url: "/api/index/get_user_list"
// })
//修改密码
export const editpassword = ({
                               password_old,
                               password,
                               password2
                             }) => service({
  url: "/api/user/edit_password",
  method: "post",
  data: {
    password_old,
    password,
    password2
  }
})
//pc 端的注册
export const registerapi = ({
                              username,
                              password,
                              password2
                            }) => service({
  url: "/api/index/sign_user",
  method: "post",
  data: {
    username,
    password,
    password2
  }
})
// pc端的登录
export const loginpcapi = ({
                             username,
                             password
                           }) => service({
  url: "/api/index/login_user",
  method: "post",
  data: {
    username,
    password
  }
})
// 商品搜索
export const searchapi = ({page, page_size, keyword}) => service({
  url: "/api/index/get_search",
  params: {
    page,
    page_size,
    keyword
  }
})
export const noOwningClick = () => service({
  url: "/api/index/no_owning_click"
})
export const functionClick = (id) => service({
  url: "/api/index/function_click?id=" + id
})
export const actClick = (id) => service({
  url: "/api/index/act_click?id=" + id
})
// 微信扫码登录
export const loginapi = () => service({
  url: "/api/index/get_login_qrcode"
})
// 拼多多二维码扫码
export const pddcopyapi = ({mp_page}) => service({
  url: "/api/goods/get_pdd_qrcode",
  params: {
    mp_page
  }
})
// 获取广告
export const getAd = () => service({
  url: "/api/index/get_ad"
})
// 轮询是否登录_copy
export const copyapi = ({token}) => service({
  url: "/api/index/get_login_status",
  method: "post",
  data: {
    token
  }
})
//首页数据
export const indexapi = () => service({
  url: '/api/index/get_index',
  method: "get"
})
// 城市分站的数据
export const cityapi = ({pid}) => service({
  url: "/api/index/get_area_data",
  params: {
    pid
  }
})
// 头部的数据
export const totalapi = () => service({
  url: "/api/index/get_web_total",
  method: "get"
})
// 推荐商品
export const hotapi = () => service({
  url: "/api/goods/top_lists"
})


// 新闻
export const newsapi = ({
                          class_id,
                          page_size,
                          page
                        }) => service({
  url: "/api/content/get_content",
  params: {
    class_id,
    page_size,
    page
  }
})
// 新闻详情
export const newdetailapi = ({
                               news_id
                             }) => service({
  url: "/api/content/get_info",
  params: {
    news_id
  }
})


//商品详情页面的数据
export const detailapi = ({
                            goods_id
                          }) => service({
  url: "/api/goods/info",
  params: {
    goods_id
  }
})
// 商品列表数据
export const listapi = ({class_id, page_size, page}) => service({
  url: "/api/goods/lists",
  params: {
    class_id,
    page_size,
    page
  }
})
// 优惠券展示
export const discountapi = () => service({
  url: "/api/coupon/get_coupon"
})
// 优惠券领取
export const getdiscountapi = ({
                                 coupon_id
                               }) => service({

  url: "/api/coupon/user_receive_coupon",
  method: "post",
  data: {
    coupon_id
  }
})


// 获取购物车数据
export const getcarapi = () => service({
  url: "/api/goods_car/get_user_car"
})
// 编辑购物车
export const editcarapi = ({id, goods_id, car_num, sku_id}) => service({
  url: "/api/goods_car/edit_user_car",
  method: "post",
  data: {
    id,
    goods_id,
    car_num,
    sku_id
  }
})
// 获取商品评价
export const getevaluateapi = ({goods_id, evaluate_type, page, page_size}) => service({
  url: "/api/goods/get_evaluate",
  params: {
    goods_id,
    evaluate_type,
    page,
    page_size
  }
})
// 删除购物车
export const delcarapi = ({ids}) => service({
  url: "/api/goods_car/del_user_car",
  method: "DELETE",
  data: {
    ids
  }
})
// 购物车订单数据
export const getorderapi = ({goods_sku_id, goods_num, coupon_id}) => service({
  url: "/api/order/get_settlement",
  method: "post",
  data: {
    goods_sku_id,
    goods_num,
    coupon_id
  }
})
// 购物车订单提交
export const ordercommitapi = ({
                                 collapse_shipping_address_id,
                                 goods_sku_id,
                                 goods_num,
                                 coupon_id,
                                 order_message
                               }) => service({
  url: "/api/order/order_commit",
  method: "post",
  data: {
    collapse_shipping_address_id,
    goods_sku_id,
    goods_num,
    coupon_id,
    order_message
  }
})


//得到商家的信息
export const getshopapi = () => service({
  url: "/api/index/mch_settled"
})
// 提交商家的信息
export const setshopapi = ({
                             name,
                             phone,
                             mch_name,
                             area,
                             address,
                             shop_type
                           }) => service({
  url: "/api/index/mch_settled",
  method: "post",
  data: {
    name,
    phone,
    mch_name,
    area,
    address,
    shop_type
  }
})
//用户获取个人信息
export const getpersonageapi = () => service({
  url: "/api/user/get_user"
})
// 用户提交个人信息
export const setpersonageapi = ({name, birthday, address, phone, gender, avatarUrl}) => service({
  url: "/api/user/set_user",
  method: "post",
  data: {
    name,
    birthday,
    address,
    phone,
    gender,
    avatarUrl
  }
})
// 获取收货地址
export const getaddressapi = () => service({
  url: "/api/user/get_collapse_shipping_address"
})
// 修改地址
export const editaddressapi = ({id, name, phone, address, area, is_default}) => service({
  url: "/api/user/set_collapse_shipping_address",
  method: "post",
  data: {
    id,
    name,
    phone,
    address,
    area,
    is_default
  }
})
// 删除收货地址
export const deladdressapi = ({id}) => service({
  url: "/api/user/del_collapse_shipping_address",
  method: "DELETE",
  data: {
    id
  }
})

// 个人中心的订单
export const getmeorderapi = ({order_status, page_size, page}) => service({
  url: "/api/order/get_user_order",
  params: {
    order_status,
    page_size,
    page
  }
})
// 个人中心订单评价
export const evaluateapi = ({order_id, sku_id, images, user_score, content}) => service({
  url: "/api/order/user_evaluate_order",
  method: "post",
  data: {
    order_id,
    sku_id,
    images,
    user_score,
    content
  }
})

// 个人中心的订单详情
export const orderdetailapi = ({order_id}) => service({
  url: "/api/order/get_user_order_info",
  params: {
    order_id
  }
})
// 支付
export const payorderapi = ({order_id}) => service({
  url: "/api/order/pay_order",
  method: "post",
  data: {
    order_id
  }
})
export const WechatPayFun = ({user_order_id}) => service({
  url: "/api/wechat_pay/pay_commit",
  method: "post",
  data: {
    user_order_id
  }
})
// 取消订单
export const cancelorderapi = ({order_id}) => service({
  url: "/api/order/cancel_user_order",
  method: "post",
  data: {
    order_id
  }
})
// 催发货
export const urgeorderapi = ({order_id}) => service({
  url: "/api/order/user_urge_order",
  method: "post",
  data: {
    order_id
  }
})
// 确认收货
export const completeorderapi = ({order_id}) => service({
  url: "/api/order/complete_order",
  method: "post",
  data: {
    order_id
  }
})
// 个人中心的售后详情
export const saledetailapi = ({order_id, goods_sku_id}) => service({
  url: "/api/order/get_after_sales_info",
  params: {
    order_id,
    goods_sku_id
  }
})
// 售后原因的数据
export const getaftersalesapi = ({id, order_id, goods_sku_id}) => service({
  url: "/api/order/get_after_sales_data",
  params: {
    id,
    order_id,
    goods_sku_id
  }
})

// 用户提交售后单
export const commitaftersaleapi = ({
                                     order_id,
                                     after_sales_id,
                                     goods_sku_id,
                                     after_sales_price,
                                     after_sales_content,
                                     after_sales_imgs,
                                     after_sales_phone
                                   }) => service({
  url: "/api/order/user_commit_after_sales",
  method: "post",
  data: {
    order_id,
    after_sales_id,
    goods_sku_id,
    after_sales_price,
    after_sales_content,
    after_sales_imgs,
    after_sales_phone
  }
})
// 完成售后
export const completesaledetailapi = ({id}) => service({
  url: "/api/order/complete_after_sales",
  method: "post",
  data: {
    id
  }
})

// 个人中心评价的详情
export const evaluateinfoapi = ({order_id, goods_sku_id}) => service({
  url: "/api/order/get_user_evaluate_info",
  params: {
    order_id,
    goods_sku_id
  }
})
// 用户充值
export const rechargeapi = ({money}) => service({
  url: "/api/user/user_recharge_money",
  method: "post",
  data: {
    money
  }
})

// 获取广告所有
export const getAdsApi = () => service({
  url: "/api/index/get_ads",
  method: "get",
  data: {}
})

// 广告点击
export const adClickApi = ({id}) => service({
  url: "/api/index/ad_click?id=" + id,
  method: "get",
  data: {}
})
// 获取任务列表
export const getUserTaskApi = () => service({
  url: "/api/user/get_user_task",
  method: "post",
  data: {}
})
// 获取任务列表
export const userAcceptTaskApi = ({task_id, status}) => service({
  url: "/api/user/accept_task",
  method: "post",
  data: {
    task_id,
    status
  }
})
// 获取任务列表
export const userUploadTaskApi = (formData) => service({
  url: "/api/user/upload_task_file",
  method: "post",
  data: formData
})

export const getMchInfoApi = () => service({
  url: "/api/index/get_mch_info",
  method: "post",
  data: {}
})
